<?php


/**
 * @author Admin
 *
 *
 */
class ImageSelectorWrapper extends EditableImageWrapper {
	
	protected $innerSectionClass = 'imgsection';
	
	protected $js = "$(document).ready( function() {
		$('.imgsection a').lightBox();
		$('.imageTitle').Truncate({length:12,spaceout:3});
		 });";

	//TODO - Insert your code here
	/**
	 *
	 */
	public  function __construct($id,$class = '') {
		parent::__construct($id,$class);
		//TODO - Insert your code here
		$this->dat = $this->HtmlElement('div');
		$this->dat->addAttribute('id', $id);
		$this->dat->addAttribute('class','image_selector_wrapper');
	}
	/**
	 * We should only ever receive image objects
	 * (non-PHPdoc)
	 * @see Display::addChild()
	 */
	public function addChild($display,$token=null){
		if( !get_class($display)){
			throw new Exception("You can only supply Image objects to Editable Image Wrappers not ".get_class($display), 90);
		}
		$frame = $this->HtmlElement('div');
		$frame->addAttribute('class', $this->innerSectionClass );
		$link = $this->HtmlElement('a',$display->output->imgs,array('alt'=>'preview image','class'=>'innerImgSelectorLink','href'=>"http://junesgallery:1967/gallery/index.php/Images/serve/".$this->imgId."/preview/500"));
		$frame = $frame->addChild( $link );
		$this->dat = $this->dat->addChild($frame);
	}
	/**
	 * last minute addition of controls
	 */
	protected function addControls( ){
		$controls = $this->HtmlElement('div');
		$controls->addAttribute('class', 'controls padding_top12');
		$title = $this->HtmlElement('span',$this->title);
		$title->addAttribute('class', 'imageTitle');
		$control_section = $this->HtmlElement( 'span',null,array('class'=> 'control_panel_right'));
		$control_option = $this->HtmlElement( 'input',null,array( 'id' => $this->imgId,'name' => 'selectedID[]','type' => 'checkbox','value'=>$this->imgId ) );
		if( $this->selected ){
			$control_option->addAttribute('checked', 'checked' );
		}
		$controls = $controls->addChild($title);
		$controls = $controls->addChild( $control_section );
		$controls = $controls->addChild( $control_option );
		$this->dat = $this->dat->addChild($controls);
	}
}


?>